/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package lyra;

import java.awt.Component;
import java.awt.Image;
import java.net.URL;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
/**
 *
 * @author Marmaridis, Mariolou, Koustas
 */
public class LYRA {

    /**
     * @param args the command line arguments
     */
    public static EntityManager e ;
    
    public static void MsgBox(String infoMessage, String titleBar)
    {
        JOptionPane.showMessageDialog(null, infoMessage, titleBar, JOptionPane.INFORMATION_MESSAGE);
    }
    
    public static int yesnocancel(String theMessage) {
        int result = JOptionPane.showConfirmDialog((Component) null, theMessage,"ΠΡΟΣΟΧΗ", JOptionPane.YES_NO_CANCEL_OPTION);
        return result;
    }
    
    public static int yesno(String theMessage) {
        int result = JOptionPane.showConfirmDialog((Component) null, theMessage,"ΠΡΟΣΟΧΗ", JOptionPane.YES_NO_OPTION);
        return result;
    }                

    public static void setFrameIcon(JInternalFrame mFrame, String iconImageURL) {
        try {
            URL mURL = LYRA.class.getClassLoader().getResource("icons/" + iconImageURL);
            ImageIcon icon = new ImageIcon(mURL);
            Image icon_img = icon.getImage();
            Image newimg = icon_img.getScaledInstance(20, 20,  java.awt.Image.SCALE_SMOOTH);
            ImageIcon newIcon = new ImageIcon(newimg);
            mFrame.setFrameIcon(newIcon);
        } catch (Exception ex) {
            ex.printStackTrace(System.out); 
        }
    }
    
    public static void main(String[] args) {
        try {
            e = javax.persistence.Persistence.createEntityManagerFactory("LYRAPU").createEntityManager();
            EntityTransaction et = e.getTransaction();
            mainForm mForm = new mainForm();
            mForm.setVisible(true);
            try {
                URL mURL = LYRA.class.getClassLoader().getResource("icons/lyra.gif");
                ImageIcon icon = new ImageIcon(mURL);
                Image icon_img = icon.getImage();
                Image newimg = icon_img.getScaledInstance(20, 20,  java.awt.Image.SCALE_SMOOTH);
                mForm.setIconImage(newimg);
            } catch (Exception ex) {
                ex.printStackTrace(System.out); 
            }
        } catch (Exception ex) {
            System.out.println("Δεν μπορεί να γίνει σύνδεση με τη βάση δεδομένων");
            ex.printStackTrace(System.out);
        }
    }
    
}
